import time

from selenium.webdriver.common.by import By
from dey15.Base import Base
from selenium.webdriver.common.keys import Keys
class Page(Base):
    url='http://10.59.9.12:7001/home/login.html'
    zh=(By.NAME,'username')
    mm=(By.NAME,'password')
    dl=(By.XPATH,'//*[@id="theForm"]/div[5]/a')
    sy=(By.LINK_TEXT,'首页')
    ss=(By.XPATH,'//*[@id="searchForm"]/div[1]/input')
    sp=(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img')
    lj=(By.XPATH,'//*[@id="buy-cart"]')
    xyb=(By.XPATH,'//*[@id="order-button"]')
    chak=(By.XPATH,'/html/body/div[4]/div[3]/span')
    def yx(self):
        self.get_url(self.url)
        time.sleep(5)
        self.send_keys(self.zh,'15649920322')
        time.sleep(2)
        self.send_keys(self.mm,'123456')
        time.sleep(10)
        self.click(self.dl)
        time.sleep(5)
        self.click(self.sy)
        time.sleep(5)
        self.send_keys(self.ss,'音乐耳机')
        time.sleep(2)
        self.send_keys(self.ss,Keys.ENTER)
        time.sleep(5)
        self.click(self.sp)
        time.sleep(2)
        self.click(self.lj)
        time.sleep(2)
        self.click(self.xyb)
        time.sleep(2)
        s=self.text(self.chak)
        assert s=='订单'
        time.sleep(2)